﻿/*
        控制窗口的js代码
        本js文件供admin_index.aspx调用
*/
var cookie = new CookieClass();
//=============================================================================
function topwin_show() {
    top.$('#topwin_tool').show();
    cookie.setCookie('topshow', 1);
}
function topwin_hide() {
    top.$('#topwin_tool').hide();
    cookie.setCookie('topshow', 0);
}
function topwin_get() {
    return top.frames["topwin"];
}
function topwin_open(url) {
    top.frames["topwin"].location = url;
}
//=============================================================================
//显示信息查看窗口
function set_statewin_show() {
    var _statewin_tool = document.getElementById('statewin_tool');
    var _statewin = $('#statewin');
    var _mainwin = $('#mainwin');
    var _mainwin_tool = $('#mainwin_tool');
    if (_statewin_tool.className == "hide") {//判断topwin是否显示        
        _mainwin.height(_mainwin.height() - _statewin.attr('height'));
        _statewin.height(200);
        _mainwin_tool.height(_mainwin.height());
        _statewin_tool.className = '';
    }
}
//信息查看窗口的显示与隐藏
function statewin_show() {
    var _statewin_tool = document.getElementById('statewin_tool');
    var _statewin = $('#statewin');
    var _mainwin = $('#mainwin');
    var _mainwin_tool = $('#mainwin_tool');
    if (_statewin_tool.className == "hide") {//判断topwin是否显示        
        _mainwin.height(_mainwin.height() - _statewin.attr('height'));
        _statewin.height(200);
        _mainwin_tool.height(_mainwin.height());
        _statewin_tool.className = '';
    }
    else {
        _mainwin.height(_mainwin.height() + _statewin.height());
        _statewin_tool.className = 'hide';
        _statewin.height(0);
    }
}
//=============================================================================
//在main窗体中打开 指定的URL
function mainwin_Open(url, topshow) {
    var mianWin = top.frames["mainwin"];
    if (mianWin != undefined)
        mianWin.location = url;
    if (topshow == null || topshow == undefined || topshow == 0) {
        topwin_hide();
    }
}
//=============================================================================
//设置左侧对象的宽高
function setLeftToolWidthAndHeight() {
    var _lefttop = $('#lefttop');
    var _leftwin = $('#leftwin');
    var _td_left = $('#td_left');
    _leftwin.height(_td_left.height() - _leftwin.position().top);
}
//隐藏左侧内容
function setLeftHide() {
     $('#td_left').hide(); ;
     var _leftopen = $('#leftopen').show();

}
//显示左侧内容
function setLeftShow() {
    var _td_left = $('#td_left').show();
    var _leftopen = $('#leftopen').hide();
}
//设置右侧容器对象的宽高
function setMainToolWidthAndHeight() {
    var _topwin_tool = document.getElementById('topwin_tool');
    var __topwin_tool = $('#topwin_tool');
    var _topwin = $('#topwin');
    var _mainwin_tool = document.getElementById('mainwin_tool');
    var __mainwin_tool = $('#mainwin_tool');
    var __mainwin = $('#mainwin');
    var _statewin_tool = document.getElementById('statewin_tool');
    var __statewin_tool = $('#statewin_tool');
    var _statewin = $('#statewin');
    var _td_main = $('#td_main');
    var _mainHeight = 0;

    if (_statewin_tool.className == 'hide') {
        _statewin.height(0);
    }
    //通过定位计算高度更精确    
    __mainwin_tool.height(document.body.clientHeight - _td_main.position().top - __topwin_tool.height() - __statewin_tool.height() - 10);
    __mainwin.height(document.body.clientHeight - _td_main.position().top - __topwin_tool.height() - __statewin_tool.height() - 10); //设置主窗口
}
//设置窗口的大小
function setWinHeightAndWidth() {

    var dheight = document.body.clientHeight;

    var dwidth = document.body.clientWidth;
    var splitwidth = $('#splitBar').width();
    var msviMastheadHeigth = $('#msviMasthead').height();
    var tool_left = $('#td_left');
    var tool_main = $('#td_main');
    tool_left.height(dheight - tool_left.position().top);
    tool_main.height(dheight - tool_main.position().top);
    tool_main.width(dwidth - tool_main.position().left);
    setLeftToolWidthAndHeight();
    setMainToolWidthAndHeight();
}
//=============================================================================
//读取cookie中的的url
function readhistory() {
    if (cookie.getCookie('mainurl') != "") {
        $("#mainwin").attr("src", cookie.getCookie('mainurl'));
    }
    if (cookie.getCookie('topshow') == 1) {
        if (cookie.getCookie('turl') != '' && cookie.getCookie('turl') != 'about:blank') {
            $("#topwin").attr("src", cookie.getCookie('turl'));
            topwin_show();
            //alert(cookie.getCookie('turl'));
        }
    }
    if (cookie.getCookie('leftwin') != "") {
        $("#leftwin").attr("src", cookie.getCookie('leftwin'));
        if (cookie.getCookie('menutip') != "") {
            setmenutip(cookie.getCookie('menutip'));
        }
    } else {
        doing('go_publish_admin');
    }
}
//设置cookie
function setmainhistory() {
    cookie.setCookie('mainurl', top.frames["mainwin"].location.href);
}
function settophistory() {
    cookie.setCookie('turl', top.frames["topwin"].location.href);
}
//=============================================================================